package cn.xuexiyuan.kpi.mapper;

import cn.xuexiyuan.kpi.entity.NodeEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description:
 * @Author 左龙龙
 * @Date 20-11-27
 * @Version 1.0
 **/
@Repository
public interface NodeMapper {

    //该注解用于返回主键
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    @Insert({ "insert into tb_node(label, father_id, value) values(#{label}, #{father_id}, #{value})"})
    void insert(NodeEntity node);

    @Select("select * from tb_node where id = #{id} limit 1")
    NodeEntity findOne(int id);

    @Delete("delete from tb_node where id = #{id}")
    int delete(NodeEntity node);

    @Select("select * from tb_node")
    List<NodeEntity> listAll();

}
